package com.xbongbong.saas.model;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.QuotationUserEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.elasticsearch.action.support.WriteRequest;

import java.util.List;
import java.util.Map;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/8/15 19:19
 * @since v1.0
 */
public interface QuotationUserModel extends IModel<QuotationUserEntity> {
    /**
     * 获取符合查询条件的记录
     *
     * @param param 查询条件
     * @return java.util.List<com.xbongbong.saas.domain.entity.QuotationUserEntity>
     * @author long.rao
     * @date 2019-08-15 19:21
     */
    List<QuotationUserEntity> findEntitys(Map<String, Object> param);

    /**
     * 保存实体
     *
     * @param contractUserEntity 客户协同人团队实体
     * @return java.lang.Integer
     * @author long.rao
     * @date 2019-08-15 19:21
     */
    Integer save(QuotationUserEntity contractUserEntity) throws XbbException;

    /**
     * 获取单个实体
     *
     * @param key    id主键
     * @param corpid 公司id
     * @return com.xbongbong.saas.domain.entity.QuotationUserEntity
     * @author long.rao
     * @date 2019-08-15 19:21
     */
    QuotationUserEntity getByKey(Long key, String corpid);

    /**
     * 查询协同团队基础列表
     * @param map 参数
     * @return 团队
     */
    List<UserTeamEntity> findBaseEntitys(Map<String,Object> map);

    /**
     * Description: 删除
     * @param quotationUserEntity 删除的数据
     * @throws XbbException
     * @author 刘阳
     * @date 2019/8/16 2:54 PM
     * @since v1.0
     */
    void delete(QuotationUserEntity quotationUserEntity) throws XbbException;

    /**
     * 批量删除
     * @param quotationIdIn 报价单id
     * @param corpid 公司id
     * @return
     */
    Integer deleteBatchByQuotationIdIn(List<Long> quotationIdIn, String corpid) throws XbbException;

    /**
     * Description: 获取报价单负责人或协同人id list
     * @param corpid 公司id
     * @param quotationId 合同id
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author 刘阳
     * @date 2019/2/20 17:15
     * @since v1.0
     */
    List<String> getQuotationUserIdList(String corpid, Long quotationId, Integer isMain);
    /**
     * Description: 获取报价单负责人或协同人 list
     * @param corpid 公司id
     * @param quotationId 合同id
     * @param isMain 是否为负责人 1负责人 0 协同人
     * @return java.util.List<java.lang.String>
     * @author 吴峰
     * @date 2021/7/27 15:21
     * @since v1.0
     */
    List<QuotationUserEntity> getQuotationUserList(String corpid, Long quotationId, Integer isMain);

    /**
     * 批量插入
     * @param insertBatchList
     */
    void insertBatch(List<QuotationUserEntity> insertBatchList, boolean isImport) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del) throws XbbException;

    void batchUpdateByUserIdIn(String corpid, List<Long> dataIdIn, List<UserTeamEntity> teamEntityList, Integer isMain, Integer del, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;

    void deleteBatchUser(List<QuotationUserEntity> quotationUserEntities, String corpid, Integer del) throws XbbException;

    Integer deleteBatch(List<Long> list, String corpid, Integer del) throws XbbException;

    /**
     * 批量解散团队依据客户id
     * @param corpid
     * @param customerIdIn
     */
    void disbandedTeamByCustomerId(String corpid, List<Long> customerIdIn) throws XbbException;

    /**
     * 批量剔除团队
     * @param corpid
     * @param removeIdList 客户团队表idList
     */
    Map<Long, String> batchDeleteById(String corpid, List<Long> removeIdList) throws XbbException;
    /**
     * 批量编辑团队
     * @param corpid
     * @param list 客户团队表idList
     * @throws XbbException
     * @return
     */
    Integer updateBatch(List<QuotationUserEntity> list, String corpid) throws XbbException;

    /**
     * 编辑团队成员标签
     *
     * @param quotationUserEntity
     */
    void editLabel(QuotationUserEntity quotationUserEntity) throws XbbException;

    /**
     * 更新协同人可编辑权限
     *
     * @param quotationUserEntity
     */
    void updateEditFormPer(QuotationUserEntity quotationUserEntity) throws XbbException;

    /**
     * 更新团队协同人信息和协同人可编辑权限
     *
     * @param corpid
     * @param idIn
     * @param updateUserToCoTeamList
     * @param coopUser
     * @param needThrow
     */
    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> updateUserToCoTeamList, Integer coopUser, boolean needThrow) throws XbbException;

    void batchUpdateCoAndPerByUserIdIn(String corpid, List<Long> idIn, List<UserTeamEntity> teamEntityList, Integer isMain, boolean needThrow, WriteRequest.RefreshPolicy refreshPolicy) throws XbbException;
}
